package main

import (
	"fmt"
	"github.com/astaxie/beego/logs"
	"net"
	"os"
	"strings"
	"time"
)

func main() {
	conn, err := net.Dial("tcp", "localhost:8080")
	if err != nil {
		fmt.Println("dial failed:", err)
		os.Exit(1)
	}
	buffer := make([]byte, 512)
	for {
		_ = conn.SetReadDeadline(time.Now().Add(5 * time.Second))
		n, err := conn.Read(buffer)
		if err != nil {
			logs.Error(err.Error())
			continue
		}
		fmt.Println("count:", n, "msg:", strings.TrimSpace(string(buffer)))
	}
}
